package com.eascs.banknet.boc.base;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.eascs.banknet.boc.vo.FtpFileTemplage;
import com.eascs.banknet.common.vo.ServerInfo;
import com.eascs.banknet.constant.EAContant;
import com.eascs.banknet.constant.FileTypeConstants;

@Component
public class BOCUtil {
	/**
	 * 怡亚通FTP接口
	 */
	@Value("${ea.ftp.href}")
	private String eaFtpHref;
	@Value("${ea.ftp.port}")
	private int eaFtpPort;
	@Value("${ea.ftp.username}")
	private String eaFtpUsername;
	@Value("${ea.ftp.password}")
	private String eaFtpPassword;
	
	/**
	 * 中行socket接口对接地址
	 */
	@Value("${boc.socket.href}")
	private String bocSockethref;
	@Value("${boc.socket.port}")
	private int bocSocketport;
	
	/**
	 * 中行中转FTP影像接口
	 */
	@Value("${boc.ftp.href}")
	private String bocFtpHref;
	@Value("${boc.ftp.port}")
	private int bocFtpPort;
	@Value("${boc.ftp.username}")
	private String bocFtpUsername;
	@Value("${boc.ftp.password}")
	private String bocFtpPassword;
	
	@Value("${boc.audit.bnkno}")
	private String bnkno;
	
	@Value("${boc.ftp.root.path}")
	private String rootPath;
	
	@Value("${boc.ftp.credit.path}")
	private String creditPath;
	@Value("${boc.ftp.contractrpt.path}")
	private String contractPath;
	@Value("${boc.ftp.loaninfo.path}")
	private String loaninfoPath;
	@Value("${boc.ftp.repayhis.path}")
	private String repayhisPath;
	
	@Value("${boc.ftp.rplanday.path}")
	private String rplandayPath;
	
	public ServerInfo getEaFtpInfo(){
		return new ServerInfo(eaFtpHref, eaFtpPort, eaFtpUsername, eaFtpPassword);
	}
	
	public ServerInfo getBocFtpInfo(){
		return new ServerInfo(bocFtpHref, bocFtpPort, bocFtpUsername, bocFtpPassword);
	}
	
	public ServerInfo getBocSocketInfo(){
		return new ServerInfo(bocSockethref, bocSocketport);
	}
	
	public FtpFileTemplage getBocFtpFileTemplate(String fileType){
		FtpFileTemplage ftpFile = new FtpFileTemplage();
		ftpFile.setFileType(fileType);
		switch (fileType) {
			case FileTypeConstants.DALIST_TYPE_ZXBGDATA:
				ftpFile.setLoadPath(creditPath);
				ftpFile.setFileType(FileTypeConstants.DALIST_TYPE_ZXBGDATA);
				ftpFile.setFileDesc(FileTypeConstants.getDatalistName(FileTypeConstants.DALIST_TYPE_ZXBGDATA));
				break;
			case FileTypeConstants.DALIST_TYPE_ZXMATE:
				ftpFile.setLoadPath(creditPath);
				ftpFile.setFileType(FileTypeConstants.DALIST_TYPE_ZXMATE);
				ftpFile.setFileDesc(FileTypeConstants.getDatalistName(FileTypeConstants.DALIST_TYPE_ZXMATE));
				break;
			case FileTypeConstants.DALIST_TYPE_SPONSOR_ZXBG:
				ftpFile.setLoadPath(creditPath);
				ftpFile.setFileType(FileTypeConstants.DALIST_TYPE_SPONSOR_ZXBG);
				ftpFile.setFileDesc(FileTypeConstants.getDatalistName(FileTypeConstants.DALIST_TYPE_SPONSOR_ZXBG));
				break;
			case FileTypeConstants.DALIST_TYPE_REFUNDCONTRACTBAK:
				ftpFile.setLoadPath(contractPath);
				ftpFile.setFileType(FileTypeConstants.DALIST_TYPE_REFUNDCONTRACTBAK);
				ftpFile.setFileDesc(FileTypeConstants.getDatalistName(FileTypeConstants.DALIST_TYPE_REFUNDCONTRACTBAK));
				break;
			case FileTypeConstants.BOC_FTPTYPE_REPAYHIS:
				ftpFile.setLoadPath(repayhisPath);
				ftpFile.setFileType(FileTypeConstants.BOC_FTPTYPE_REPAYHIS);
				break;
			case FileTypeConstants.BOC_FTPTYPE_RPPLANLOOP:
				ftpFile.setLoadPath(rplandayPath);
				ftpFile.setFileType(FileTypeConstants.BOC_FTPTYPE_RPPLANLOOP);
				break;
			case FileTypeConstants.BOC_FTPTYPE_RPPLANSTATIC:
				ftpFile.setLoadPath(rplandayPath);
				ftpFile.setFileType(FileTypeConstants.BOC_FTPTYPE_RPPLANSTATIC);
				break;
			default:
				break;
		}
		return ftpFile;
	}
	
	public String getRootPath() {
		return rootPath;
	}

	public void setRootPath(String rootPath) {
		this.rootPath = rootPath;
	}

	public String getBnkno() {
		return bnkno;
	}

	public void setBnkno(String bnkno) {
		this.bnkno = bnkno;
	}
	
	
}
